package com.winspread.app

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import com.blankj.utilcode.util.ActivityUtils
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.concurrent.atomic.AtomicBoolean

class SplashActivity : AppCompatActivity() {
    private var keepOnScreen = AtomicBoolean(true)
    override fun onCreate(savedInstanceState: Bundle?) {
        val splashScreen = installSplashScreen()
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)

        //设置闪屏页时间
        lifecycleScope.launch {
            delay(10)
            keepOnScreen.compareAndSet(true, false)
            delay(2000)
            ActivityUtils.startActivity(MainActivity::class.java)
        }

        splashScreen.setKeepVisibleCondition {
            keepOnScreen.get()
        }


    }
}